
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { SceneManager } from './SceneManager';
import DataManager from './Runtime/DataManager';
import { ItemStatusEnum, ItemTypeEnum, SceneEnum } from '../Enum';
const { ccclass, property } = _decorator;



@ccclass('H4SceneManager')
export class H4SceneManager extends SceneManager {
    type: SceneEnum = SceneEnum.H4;
    @property(Prefab)
    MailPrefab: Prefab = null;

    @property(Node)
    MailPlaceholder: Node = null;

    render() {
        super.render();
        this.items.destroyAllChildren();

        const key = DataManager.Instance.items.find(i => i.type === ItemTypeEnum.MAIL)
        if (key && key.status === ItemStatusEnum.Scene) {
            const keyNode = instantiate(this.MailPrefab)
            this.items.addChild(keyNode)
            keyNode.setPosition(this.MailPlaceholder.position)
        }
    }

}

